//
//  DLWeChatPayOrAuthToolsShareManager.h
//  DGGSharePaySDK
//
//  Created by Dracy on 2019/8/20.
//  Copyright © 2019 dl_hzk. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UMShare/UMShare.h>
#import "WXApiObject.h"

NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, DLWeChatPayOrAuthCustomPlatformType);

typedef NS_ENUM(NSUInteger,WXShareCallBackStatusType){
    WXShareCallBackStatusTypeSuccess = 0,//分享成功
    WXShareCallBackStatusTypeCancel = 1,//分享取消
    WXShareCallBackStatusTypeFail = 2,//分享失败
};

typedef NSString * DLWeChatPayToolsParameterKey NS_STRING_ENUM;
FOUNDATION_EXTERN DLWeChatPayToolsParameterKey const DLWeChatPayToolsParameterAPPIDKey;
FOUNDATION_EXTERN DLWeChatPayToolsParameterKey const DLWeChatPayToolsParameterPartnerIDKey;
FOUNDATION_EXTERN DLWeChatPayToolsParameterKey const DLWeChatPayToolsParameterBussinessAPIKey;
FOUNDATION_EXTERN DLWeChatPayToolsParameterKey const DLWeChatPayToolsParameterOrderRequestStringKey; //服务器拼好的支付请求串
FOUNDATION_EXTERN DLWeChatPayToolsParameterKey const DLWeChatPayToolsParameterAPPSchemeKey;//应用注册scheme,在AliSDKDemo-Info.plist定义URL types
typedef void(^DLWeChatPayManagerBack)(id errStr);

@class DLWeChatPayOrAuthToolsManager;
@protocol WXSharedMesaageDelegate<NSObject>

/**
 * 分享结果回调
 */
- (void)dl_sharedMessageCallBack:(BOOL)success responseData:(UMSocialShareResponse *)response error:(NSError *)error;

/**
 * 分享结果回调 带状态
 */
- (void)dl_sharedMessageCallBackStatusType:(WXShareCallBackStatusType)statusType responseData:(UMSocialShareResponse *)response error:(NSError *)error;


/**
 * 分享面板显示或者隐藏回调
 */
- (void)dl_sharedMenuViewDisPlay:(BOOL)show;

/**
 * 检测用户是否配置了自定义分享，如有，请调用（dl_shareAddCustomePlatform:iconImage:platformName:）方法添加并实现回调
 */
- (void)dl_shareCustomeConfigCheck:(DLWeChatPayOrAuthToolsManager *)shareManager;

/**
 * 用户自定义分享，点击分享按钮回调
 */
- (void)dl_shareCustomePlatform:(DLWeChatPayOrAuthCustomPlatformType)platform withUserInfo:(NSDictionary *)userInfo;

@end


@interface DLWeChatPayOrAuthToolsManager : NSObject


+ (instancetype)sharedInstance;

///分享回调代理
@property (nonatomic, weak) id<WXSharedMesaageDelegate> delegate;
///分享结果回调
@property (nonatomic, strong) void(^dl_sharedMessageCallBack)(BOOL success, UMSocialShareResponse *response, NSError *error);
///分享回调带状态
@property (nonatomic, copy) void(^dl_shareMessageWithStatusCallBack)(WXShareCallBackStatusType callBackStatusType,UMSocialShareResponse*response,NSError *error);
///分享面板显示或者隐藏回调
@property (nonatomic, strong) void(^dl_sharedMenuViewDisPlayBlock)(BOOL isShow);
///自定义分享面板
@property (nonatomic, assign) BOOL customWxShareUI;
///分享类型
@property (nonatomic, assign) DLWeChatPayOrAuthCustomPlatformType WXSharePlatformType;

#pragma mark - 分享
/**
 分享网页信息（已废弃，勿调用）
 @param platformType 分享平台
 @param url 网页地址
 @param thumbURL 缩略图
 @param title 网页标题
 @param content 网页标题内容
 */
- (void)dl_shareToWX:(UMSocialPlatformType)platformType
         withMediaURL:(NSString *)url
             thumbURL:(NSString *)thumbURL
                title:(NSString *)title
              content:(NSString *)content;

/**
 分享网页信息
 @param url 网页地址
 @param thumbURL 缩略图
 @param title 网页标题
 @param content 网页标题内容
 */
- (void)dl_shareWithMediaURL:(NSString *)url
             thumbURL:(NSString *)thumbURL
                title:(NSString *)title
              content:(NSString *)content;

/**
 用户添加自定义分享平台
 @param platformType 分享平台
 @param iconImage icon图片
 @param platformName 平台名称
 */
- (void)dl_shareAddCustomePlatform:(DLWeChatPayOrAuthCustomPlatformType)platformType
                          iconImage:(UIImage *)iconImage
                       platformName:(NSString *)platformName;

/// 直接分享图片到微信
/// @param sence 分享场景
/// @param image 分享的图片

- (void)dgg_shareImageToWXPlatformWithSence:(enum WXScene)sence image:(UIImage *)image;

#pragma mark - 支付/授权

//-------------------------通用---------------

/**
 是否是支付
 */
+ (BOOL)dl_isHandlePayURL:(NSURL *)theURL;

/**
handle open url
*/
- (BOOL)dl_handleOpenURL:(NSURL *)theURL;

/**
 handle open url
 */
- (BOOL)dl_handleOpenURL:(NSURL *)theURL universalLink:(NSUserActivity *)userActivity;

/*
 微信/支付宝授权
 */
- (void)dl_WeiXinWithAuthParameter:(id)parameter schemeKey:(NSString *)schemeKey callBack:(DLWeChatPayManagerBack)payBack;

/*
 微信打开小程序
 */
- (void)dl_WeiXinMiniProgramWithUserName:(NSString *)userName
                                    path:(NSString *)path
                         miniProgramType:(NSUInteger)miniProgramType
                                  extMsg:(NSString *)extMsg
                                 extDict:(NSDictionary *)extDict
                                response:(void (^)(NSDictionary * _Nullable response, NSError * _Nullable err))theResponse;

//------------------------------微信--------------------------

/**
 微信是否安装
 */
+ (BOOL)dl_WeiXinIsInstalled;

/**
 handle open url
 */
- (BOOL)dl_WeiXinHandleOpenURL:(NSURL *)theUrl;


/**
 微信发起支付
 
 @param theParam 支付相关参数-服务器返回的参数需增加appid，partnerid、bussinessapikey
 @param theResponse 支付结果
 */
- (void)dl_WeiXinPayWithParameters:(NSDictionary <DLWeChatPayToolsParameterKey, id> *)theParam response:(void (^)(NSDictionary * _Nullable response, NSError * _Nullable err))theResponse;

@end

NS_ASSUME_NONNULL_END
